<?php $html->css('/assets/css/gallery.css',null,array(),false);?>
<?php 
	$loop = 1;
	foreach($eventAssets as $eventAsset){?>
		<div class="galleryImage" style="clear: none; margin-top: 10px;">
			<?php echo $asset->previewImage($eventAsset['EventAsset'],array('thumb'=>array('width'=>'60','height'=>'60','crop'=>false)));?>
			<?php 
			if(!isset($allowDefaultSelect) || $allowDefaultSelect == true)
				echo '<br />'.$form->input("EventAsset.is_default",array(
					'title'=>__("Set as default image for the event"),
					'style'=>"marging-left:3px;",
					'type'=>'radio',
					'checked'=>$eventAsset['EventAsset']['is_default'] ? 1:"",
					'options'=>array($eventAsset['EventAsset']['id']=>""),
					'value'=>1,
					'div'=>false,
					'legend'=>false,
					'label'=>false,
					'div'=>false
				)
			)
			?>
			<?php echo $html->link("",array(
				"plugin"=>"events",
				"controller"=>"event_assets",
				'action'=>"delete",
				$eventAsset['EventAsset']['id']),
				array(
					'style'=>"padding-top:0px !important",
					"class"=>"delete_link crossIcon",
					'onclick'=>"return confirmAndAjaxCall(this,'".__("Are you sure you want to delete this image?")."')"
				)
			);?>
		</div>
		<?php if($loop%3 == 0)
			echo '<div class="clear"></div>';
			$loop++;
		?>
<?php } ?>
<script>
	function confirmAndAjaxCall(caller,msg)
	{
		if(confirm(msg))
		{
			var fn = function(){
				if(typeof countCheck == "function")
				{
					countCheck.call($('#asset_inputs_parent_field_add_more').parent()[0]);
				}
			};
			$.get($(caller).attr("href"));
			$(caller).closest(".galleryImage").hide('slow',function(){
				$(this).remove();
				fn();
			});
			setTimeout(fn,200);
		}
		return false;
	}
</script>